
             
/**
 * 
 *
 * @File name:  QueryByPagerAction.java 
 * @Create on:  2011-10-30 23:38:961
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        
package com.boho.estates.query.action;

            
import java.sql.Connection;
import java.util.Date;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.Pager;
import cn.boho.framework.service.MessageService;
import cn.boho.framework.utils.DateUtils;

import com.boho.base.dao.DaoHelper;
import com.boho.estates.query.dao.QueryDao;

public class QueryByPagerAction extends ActionImp {
	
	//条形码，资产名称，购买日期，购买价格，资产类型，资产性质，所属部门，使用管理人，保修期
	
	private Connection con=null;
	private Pager pager=null;
	private int pageSize = 100;
	private int currentPage = 1;
	private Integer barCode;
	private String name;
	private Date date1;
	private Date date2;
	private double p1;
	private double p2;
	private String type;
	private String nature;
	private Integer departNo;
	private String manager;
	private String warranty;
	
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		atx.setErrorContext("BOHO_COMMON_1004", MessageService.getMessage("BOHO_COMMON_1004"),"【综合信息】" ,ex);
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		pager = new Pager(pageSize, currentPage);
		ComboPager cp = QueryDao.queryByPager(con, pager, barCode, name, date1, date2, p1, p2, type, nature, departNo, manager, warranty);
		DaoHelper.setDictField(con, cp, "FIXED_ASSETS_TYPE", "", "FIXED_ASSETS_TYPE");
		atx.setValue("T_QUERY", cp);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		if(atx.getStringValue("PAGE_SIZE")!=null&&!atx.getStringValue("PAGE_SIZE").equals("")){
			pageSize = new Integer(atx.getStringValue("PAGE_SIZE"));
		}
		if(atx.getStringValue("CURRENT_PAGE")!=null&&!atx.getStringValue("CURRENT_PAGE").equals("")){
			currentPage = new Integer(atx.getStringValue("CURRENT_PAGE"));
		}
		
		barCode = atx.getIntegerValue("BARCODE", -1);
		name = atx.getStringValue("NAME", "");
		String d1 = atx.getStringValue("DATE1", null);
		String d2 = atx.getStringValue("DATE2", null);
		date1 = (d1 != null ? DateUtils.parse(d1) : null);
		date2 = (d2 != null ? DateUtils.parse(d2) : null);
		p1 = atx.getDoubleValue("P1", -1.0);
		p2 = atx.getDoubleValue("P2", -1.0);
		type = atx.getStringValue("FIXED_ASSETS_TYPE", "");
		nature = atx.getStringValue("FIXED_ASSETS_NATURE", "");
		departNo = atx.getIntegerValue("DEPARTMENT_NO", -1);
		manager = atx.getStringValue("WITH_MANANGER", "");
		warranty = atx.getStringValue("WARRANTY", "");
		return 1;
	}
}
